<%@ page import="org.apache.ibatis.session.SqlSession" %>
<%@ page import="org.apache.ibatis.session.SqlSessionFactory" %>
<%@ page import="com.touzi.constants.DbCons" %>
<%@ page import="com.touzi.mapper.ChanpinMapper" %>
<%@ page import="java.util.List" %>
<%@ page import="com.touzi.beans.dbs.chanpin.Chanpin" %><%--
  Created by IntelliJ IDEA.
  User: w7851
  Date: 2018/5/15
  Time: 10:32
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
<%
    SqlSession sqlSession = ((SqlSessionFactory) application.getAttribute(DbCons.DB_FACTORY)).openSession();
    ChanpinMapper mapper = sqlSession.getMapper(ChanpinMapper.class);
    List<Chanpin> chanpins = mapper.selectAllKeY();

    sqlSession.close();
    request.setAttribute("list", chanpins);

%>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>欢迎光临创富商城</title>
    <meta content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0" name="viewport"/>

    <meta content="yes" name="apple-mobile-web-app-capable"/>
    <meta content="black" name="apple-mobile-web-app-status-bar-style"/>
    <meta content="telephone=no" name="format-detection"/>

    <link rel="stylesheet" href="/css/ydui.css">
    <script src="/js/ydui.flexible.js"></script>
    <style type="text/css">
        .xuanzed {
            color: #E8574E;
        }

        .xuanchuan {
            width: 100%;
            height: 3rem;
        }

        .chanpin {
            position: relative;
            height: 140px;
            margin: 16px 0px;
            background-color: white;
        }

        .chanpintut {
            width: 120px;
            height: 120px;
            margin-top: 10px;
            margin-left: 10px;
        }

        .chanpinshuoming {
            position: absolute;
            left: 140px;
            top: 10px;
        }

        .buybtn {
            font-size: 14px;
            text-align: center;
            border: red solid 1px;
            border-radius: 16px;
            padding: 8px 16px;
            position: absolute;
            right: 10px;
            bottom: 10px;
        }

        .buybtndis {
            color: #888;
        }

        .buybtn:active {
            background-color: red;
        }

        .miaoshu {
            color: #888;
        }

        .timu {
            font-size: 20px;
        }

        .text p {
            margin: 2px 0px;
        }

        .money {
            color: red;
        }

    </style>
</head>
<body>
<div class="g-flexview">

    <header class="m-navbar  navbar-fixed">
        <div class="navbar-center"><span class="navbar-title">欢迎</span></div>
    </header>


    <div class="g-scrollview" style="margin-top: 0.9rem;margin-bottom: 0.9rem">
        <div>
            <img class="xuanchuan"
                 src="/pics/xuanchuan.png">
        </div>

        <c:forEach var="chanpin" items="${list}">
            <%--//id | biaoti       | jiage | xiangou | fenhongcishu | fenhongzhouqi | shengyu | fenhong | paixu | keyong--%>
            <div class="chanpin">
                <img class="chanpintut"
                     src="/pics/money.jpg">
                <div class="chanpinshuoming">
                    <div class="text">
                        <p class="timu">${chanpin.biaoti}&nbsp;&nbsp;<span class="money">￥${chanpin.jiage}</span></p>
                        <p class="miaoshu">分红次数:${chanpin.fenhongcishu}</p>
                        <p class="miaoshu">分红周期:${chanpin.fenhongzhouqi}</p>
                        <p class="miaoshu">每次分红:${chanpin.fenhong}</p>
                        <p class="miaoshu">库存剩余:${chanpin.shengyu}</p>
                    </div>
                </div>
                <c:if test="${chanpin.shengyu<=0}">
                    <a href="javascript:void(0)">
                        <div class="buybtn buybtndis">已售罄</div>
                    </a>
                </c:if>
                <c:if test="${chanpin.shengyu>0}">
                    <a href="/mobile?method=toconformbuy&chanpinid=${chanpin.id}">
                        <div class="buybtn">立即购买</div>
                    </a>
                </c:if>
            </div>
        </c:forEach>

    </div>

    <footer class="m-tabbar tabbar-fixed">
        <a href="javascript:void(0)" class="tabbar-item">
        <span class="tabbar-icon">
           <i class="icon-home xuanzed"></i>
        </span>
            <span class="tabbar-txt xuanzed">首页</span>
        </a>

        <a href="/mobile?method=gomobilepage&page=my" class="tabbar-item">
        <span class="tabbar-icon">
            <i class="icon-ucenter-outline"></i>
        </span>
            <span class="tabbar-txt">我的</span>
        </a>

        <a href="/mobile/share.jsp" class="tabbar-item">
        <span class="tabbar-icon">
            <i class="icon-share1"></i>
        </span>
            <span class="tabbar-txt">邀请</span>
        </a>
    </footer>

</div>
</body>
<script type="text/javascript">

</script>
</html>
